// ASCII Table - ACW
// Joe Pardue April 10, 2009
// This program outputs as ASCII Table to 
// a PC Terminal

#include "libACW001.h"

int main(void)
{
init();		// Initialize private stuff
setup(); 	// Setup the public stuff

for (;;) 	// Call loop() forever

	loop();

return 0;	// You never get here.
}

/*
  ASCII table
 
 Prints out byte values in all possible formats:  
 * as raw binary values
 * as ASCII-encoded decimal, hex, octal, and binary values
 
 For more on ASCII, see http://www.asciitable.com and http://en.wikipedia.org/wiki/ASCII
 
 The circuit:  No external hardware needed.
 
 created 2006
 by Nicholas Zambetti 
 modified 18 Jan 2009
 by Tom Igoe
 
 This example code is in the public domain.

 <http://www.zambetti.com> 
 
 */
void setup() 
{ 
  //Serial.begin(9600); 	//TAW
  serialBegin(9600);


  // prints title with ending line break 
  //Serial.println("ASCII Table ~ Character Map"); 
  printf("ASCII Table - Character Map\n");

  // wait for the long string to be sent
  delay(100);
} 

// first visible ASCIIcharacter '!' is number 33:
// int thisByte = 33; 		//TAW

//int number = '!';
int number= 33;

// you can also write ASCII characters in single quotes.
// for example. '!' is the same as 33, so you could also use this:
//int thisByte = '!';  

void loop() 
{ 
  // prints value unaltered, i.e. the raw binary version of the 
  // byte. The serial monitor interprets all bytes as 
  // ASCII, so 33, the first number,  will show up as '!' 
  //Serial.print(thisByte, BYTE);    // TAW
  printf("%c", number);


  //Serial.print(", dec: "); 		// TAW
  // prints value as string as an ASCII-encoded decimal (base 10).
  // Decimal is the  default format for Serial.print() and Serial.println(),
  // so no modifier is needed:
  //Serial.print(thisByte);  		// TAW    
  // But you can declare the modifier for decimal if you want to.
  //this also works if you uncomment it:

  // Serial.print(thisByte, DEC);  

  printf(", dec: %u", number);

  //Serial.print(", hex: "); 		// TAW
  // prints value as string in hexadecimal (base 16):
  //Serial.print(thisByte, HEX);   	// TAW
  
  printf(", hex: 0x%x", number);  

  //Serial.print(", oct: "); 		// TAW
  // prints value as string in octal (base 8);
  //Serial.print(thisByte, OCT); 	// TAW
  
  printf(", oct: %o", number);
  
  // also prints ending line break   
  printf("\n");

  //Serial.print(", bin: "); 		// TAW
  // prints value as string in binary (base 2) 
  // also prints ending line break:
  //Serial.println(thisByte, BIN); 	// TAW  

  // if printed last visible character '~' or 126, stop: 
  //if(thisByte == 126) {     // you could also use if (thisByte == '~') {	// TAW
    // This loop loops forever and does nothing
  
  if (number == 126)
  {
  
    while(1) //true) 
	{ 
      continue; 
    } 
  } 
  // go on to the next character
  //thisByte++;  					// TAW
  number++;

  // allow some time for the Serial data
  // to be sent
  delay(100);
}

